package com.mingda.weathermagiccenter.mapper;

import com.mingda.weathermagiccenter.pojo.WsEquisurfaceData;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
* @author Administrator
* @description 针对表【ws_equisurface_data(气象等值面数据表)】的数据库操作Mapper
* @createDate 2025-06-05 09:28:29
* @Entity com.mingda.weathermagiccenter.pojo.WsEquisurfaceData
*/
public interface WsEquisurfaceDataMapper extends BaseMapper<WsEquisurfaceData> {

    @Insert("INSERT INTO ws_equisurface_data (id, orgid, orgname, wdate, wtype, wsource, geom, ctime, flag, legend, projectid) "
		+ "VALUES (#{id}, #{orgid}, #{orgname}, #{wdate}, #{wtype}, #{wsource}, #{geom} :: text, NOW(), #{flag}, #{legend} :: jsonb, #{projectid})")
	public void saveWsEquisurfaceData(WsEquisurfaceData wsEquisurfaceData);

    @Update(" WITH a AS (update ws_equisurface_data set wtype=#{wtype}, wsource=#{wsource}, geom=#{geom} :: text, ctime=NOW(), legend=#{legend} :: jsonb, projectid=#{projectid} "
			+ " where wdate=#{wdate} and orgid=#{orgid} and wtype=#{wtype} and wsource=#{wsource} and projectid=#{projectid} returning *) "
			+ " INSERT INTO ws_equisurface_data (id, orgid, orgname, wdate, wtype, wsource, geom, ctime, flag, legend, projectid) "
			+ " select #{id}, #{orgid}, #{orgname}, #{wdate}, #{wtype}, #{wsource}, #{geom} :: text, NOW(), #{flag}, #{legend} :: jsonb, #{projectid} "
			+ " where (select count(*) from a) = 0 ")
	public void mergnWsEquisurfaceData(WsEquisurfaceData wsEquisurfaceData);

}




